package com.shanzmoo.core.domain.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.shanzmoo.db.module.msys.entity.MSysMenuEntity;
import com.shanzmoo.db.module.psys.entity.PSysMenuEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * 菜单保存对象
 * @author: Gzhao 2020/11/10
 */
@Data
@Accessors(chain = true)
@ApiModel("人员菜单列表")
public class MenuAuthVO {

    @JsonIgnore
    @ApiModelProperty(value = "菜单Id", hidden = true)
    private Integer menuId;

    @ApiModelProperty("菜单名称")
    private String title;

    @ApiModelProperty("前端组件路径")
    private String path;

    @ApiModelProperty("图标")
    private String icon;

    @ApiModelProperty("是否隐藏菜单")
    private Boolean hidden;

    @ApiModelProperty("权限标识")
    private String perms;

    @ApiModelProperty("子菜单")
    private List<MenuAuthVO> children;

    public static MenuAuthVO create(MSysMenuEntity entity) {
        MenuAuthVO menuAuthVO = new MenuAuthVO();
        menuAuthVO.setMenuId(entity.getMenuId());
        menuAuthVO.setTitle(entity.getTitle());
        menuAuthVO.setPath(entity.getPath());
        menuAuthVO.setIcon(entity.getIcon());
        menuAuthVO.setHidden(entity.getHidden());
        menuAuthVO.setPerms(entity.getPerms());

        return menuAuthVO;
    }

    public static MenuAuthVO create(PSysMenuEntity entity) {
        MenuAuthVO menuAuthVO = new MenuAuthVO();
        menuAuthVO.setMenuId(entity.getId());
        menuAuthVO.setTitle(entity.getTitle());
        menuAuthVO.setPath(entity.getPath());
        menuAuthVO.setIcon(entity.getIcon());
        menuAuthVO.setHidden(entity.getHidden());
        menuAuthVO.setPerms(entity.getPerms());

        return menuAuthVO;
    }
}
